﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
using System.Collections.Generic;
namespace WPFExcelReport
{
    public partial class TSAP04
    {
        public TSAP04()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VAPFOLGE();
            DataContext = MV;
            InitializeComponent();
        }

        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);              
        } 

        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return; 
            base.Window_Loaded(sender, e);        
        }
        public override void OnEXAUFChg(string vlaue)
        {
            TBMain.Clear();
            if (EXAUF.Length < 8)
                return;
            dwData = TMV.TBMain.NewRow();           
            dwData["APFMANDANT"] = app.Mandant;
            dwData["APFANRKRS"] = " AND APFANRKRS='" + EXAUF.Substring(0, 2) + "'";
            dwData["APFALFDNR"] = " AND APFALFDNR='" + EXAUF.Substring(2, 6) + "'";
            SResult = TMV.QAPF01(dwData);
            MergeData(SResult, false);
            base.OnEXAUFChg(vlaue);
        }
        
        public override void LOADBYAUF()
        {
            Locate("KEY", ORDERNUM);
            base.LOADBYAUF();
        }

        public override void ManageCommand(object sender, RoutedEventArgs e)
        {
            if (IsManage)
            {
                OnEXAUFChg(EXAUF);
            }
            base.ManageCommand(sender, e);
        } 
    }

}
